from selenium import webdriver
import time

path = 'chromedriver.exe'

browser = webdriver.Chrome(path)

url = 'http://www.baidu.com'

browser.get(url)

time.sleep(3)

input = browser.find_element_by_id('kw')

input.send_keys('迪丽热巴')

time.sleep(3)

button = browser.find_element_by_id('su')
button.click()

time.sleep(3)

browser.back()

time.sleep(3)

browser.forward()

time.sleep(3)

# 页面下滑
js = 'document.documentElement.scrollTop=100000'
browser.execute_script(js)

time.sleep(3)

a = browser.find_elements_by_xpath('//a[@class="n"]')[0]
a.click()

time.sleep(5)
browser.quit()
